from flask import Flask, make_response

app = Flask(__name__)

"""
方式1:返回一个元祖, 元组必须是(response, status, headers)形式, 且至少包含一个元素, status 值会覆盖状态代码， headers 可以是一个列表或字典，作为额外的消息标头值
方式2:make_response
"""


"""
Request URL:http://127.0.0.1:5000/
Request Method:GET
Status Code:888 UNKNOWN
Remote Address:127.0.0.1:5000
Referrer Policy:no-referrer-when-downgrade
Response Headers
view source
Content-Length:5
Content-Type:text/html; charset=utf-8
Date:Tue, 24 Dec 2019 03:04:41 GMT
name:list
Server:Werkzeug/0.16.0 Python/3.7.4
"""
@app.route('/')
def index():
    #方式1
    #return 'hello', 888, {'name':'list'}
    #方式2
    resp = make_response("test")
    resp.headers['name'] = 'lisi'
    resp.status = "888"
    return resp


if __name__ == '__main__':
    app.run()